# -*- coding:utf-8 -*-
#频度计数

vowels = ["a","e","i","o","u"]
word = input("Provide a word to search for vowels:")
found = {}

# found["a"]=0
# found["e"]=0
# found["i"]=0
# found["o"]=0         五行直接用下面一行代码顶替,设置一个初始值
# found["u"]=0
found = found.fromkeys(vowels,0)

for letter in word:
    if letter in vowels:
        found[letter] += 1
print(found.items())

for k,v in found.items():
    print(k,"was found",v,"time(s)")
print(found)


#使用dict.setdefault()

vowels = ["a","e","i","o","u"]
word = input("Provide a word to search for vowels:")
found = {}
for letter in word:
    if letter in vowels:
 #       found[letter] += 1   如果只写这一行会报错，因为没有初始化频度数，这里引入setdefault
         found.setdefault(letter,0)
         found[letter] +=1
for k,v in sorted(found.items()):
    print(k,'was found',v,'time(s).')


# 最终版
vowels = set('aeiou')
word = input("Provide a word search for vowels:")
found = vowels.intersection(set(word))
for vowel in found:
    print(vowel)